package main
import (
	"fmt"
)

type Person struct {
	Name string
	Age int
	Scores [5]float64
	ptr *int
	slice []int
	map1 map[string]string
}

func main() {
	var p1 Person
	// var p1 Person = Person{"", 0}
	// var p1 *Person = new (Person) new关键字创建的是结构体的指针 赋值应用 (*p1).name || p1.name
	// var p1 *Person = &Person{}
	// go作者为了方便 将指针取值简化成 p1.name

	p1.slice = make([]int, 10)
	p1.slice[0] = 100
	p1.map1 = make(map [string]string)
	p1.map1["key1"] = "map"
	fmt.Println("p1:", p1)

	fmt.Println("------------------")

	p2 := p1 // 结构体是值类型 深拷贝
	p2.Name = "狐狸精"
	fmt.Println("p1:", p1)
	fmt.Println("p2:", p2)

	fmt.Println("------------------")

	p3 := &p1 // 结构体浅拷贝
	(*p3).Name = "孙悟空"
	fmt.Println("p1:", p1)
	fmt.Println("p2:", p2)
	fmt.Println("p3:", *p3)
}